package com.jprocms.module.cms.dal.mysql.type;


import com.jpro.framework.common.pojo.PageResult;
import com.jpro.framework.mybatis.core.mapper.BaseMapperX;
import com.jpro.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.jprocms.module.cms.controller.admin.type.vo.CmsTypePageReqVO;
import com.jprocms.module.cms.dal.dataobject.type.CmsTypeDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 内容类型 Mapper
 *
 * @author jprocms
 */
@Mapper
public interface CmsTypeMapper extends BaseMapperX<CmsTypeDO> {

    default PageResult<CmsTypeDO> selectPage(CmsTypePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CmsTypeDO>()
                .likeIfPresent(CmsTypeDO::getName, reqVO.getName())
                .eqIfPresent(CmsTypeDO::getTypeGroup, reqVO.getTypeGroup())
                .orderByDesc(CmsTypeDO::getId));
    }

    default List<CmsTypeDO> selectList(CmsTypePageReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<CmsTypeDO>()
                .likeIfPresent(CmsTypeDO::getName, reqVO.getName())
                .eqIfPresent(CmsTypeDO::getTypeGroup, reqVO.getTypeGroup())
                .orderByDesc(CmsTypeDO::getId));
    }
}